<script setup lang="ts">

import {ref,defineProps} from 'vue'
import {onLoad, onShareAppMessage,onShareTimeline} from '@dcloudio/uni-app'
import useShare from '@/mixins/share'
import {shareUtils} from '@/utils/share'
const {getShareCover} = useShare()
const props = defineProps({
  url:{
    type:String,
    default:''
  },
  
})

onLoad((option)=>{
  // uni.setNavigationBarTitle({
  //   title:option.title
  // })
})



const page = getCurrentPages().pop()
let path: string = `${page.route}?url=${props.url}`
const share_path = shareUtils.buildPathQuery(path)

// debugger
onShareAppMessage(() => {

  const promise = new Promise(resolve => {
    getShareCover(path, null, null).then(res => {

      res.path = share_path

      // debugger
      resolve(res)

    })
  })

  return {
    path: share_path,
    imageUrl: null,
    promise
  }
})



onShareTimeline(() => {

  const promise = new Promise(resolve => {
    getShareCover(path, null, null).then(res => {

      res.path = share_path

      // debugger
      resolve(res)

    })
  })

  return {
    path: share_path,
    imageUrl: null,
    promise
  }
})


</script>

<template>
  <MidLayout>
  <web-view :src="url"></web-view>
  </MidLayout>
</template>

<style scoped lang="scss"></style>
